﻿//*************************************************************************
//面向服务的协作式智能交通系统仿真软件SoC-ITSS v2.1 alpha
//发布单位：西北工业大学--巴黎高科MINES机器人与群智能系统联合实验室
//团队负责人：张凯龙 Zhang Kailong
//团队成员：张大方、杨安胜、王敏、谢策、王雨佳、谢尘玉等
//联系我们：kl.zhang@nwpu.edu.cn
//2012-2021
//*************************************************************************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CyberCarSimulation.Bean;

//*******************************************************
//
//文件名(File Name):           Definitions.cs
//
//数据表(Tables):              nothing 
//
//          修改理由：         定义属性
//
//*******************************************************
namespace CyberCarSimulation.Regulation
{
    class Definitions
    {
        /*仿真类型*/
        public const int SimuTest = 1;             //Test模式
        public const int SimuTcross = 2;           //T型路口模式
        public const int SimuCross = 3;            //全十字路口模式

        /*优先级权重因子的设置 WM*/
        public const int xishu1 = 100;
        public const int xishu2 = 10;
        public const int xishu3 = 1;

        /*调度模式选择，优先级调度、FIFO调度、信号灯调度*/
        public const int SchePrioFIFO = 1;         //
        public const int ScheFIFO = 2;             //
        public const int ScheLight = 3;            //信号灯调度
        public const int ScheMultiPrioFIFO = 4;    //基于优先级
        public const int ScheMultiFIFO = 5;        //先来先服务
        public const int ScheNew = 6;              //

        /*车辆发送的消息类型*/
        public const int MsgPrefix = 71600;        //消息前缀
        public const int MsgReservation = 71601;   //预约信息
        public const int MsgRenew = 71602;         //更新状态消息
        public const int MsgWait = 71603;          //等待临界区消息
        public const int MsgPassing = 71604;       //通过消息
        public const int MsgRelease = 71605;       //离开临界区消息
        public const int MsgFault = 71606;         //车辆故障信息
        public const int MsgBroad = 71607;         //车辆广播信息
        public const int MsgPassed = 71608;        //车辆离开转弯区信息

        /*调度器发送的消息类型*/
        public const int MsgAuthorize = 71611;     //授权信息
        public const int MsgRefuse = 71612;        //拒绝授权信息
        public const int MsgRaisePrio = 71613;     //拒绝授权信息


        /*车辆发送给交通云的消息类型*/
        public const int MsgApply = 94071300;       //申请规划消息
        public const int MsgBreakdown = 94071301;   //车辆损毁消息
        public const int MsgUpdate = 94071302;      //车辆更新消息

        /*交通云发送给车辆的消息类型*/
        public const int MsgFeedback = 94071310;    //交通云反馈消息

        /*路口编号*/
        public const int Cross1 = 1;                //路口1
        public const int Cross2 = 2;                //路口2

        /*道路编号*/
        public const int WtoE_Lane = 1;             //西到东
        public const int EtoW_Lane = 2;             //东到西
        public const int NtoS_Lane = 3;             //北到南
        public const int StoN_Lane = 4;             //南到北

        /*车辆状态编号*/
        public const int StatePrefix = 2800;        //状态前缀
        public const int Init = 2801;               //初始状态
        public const int Entering = 2802;           //进入状态
        public const int Following = 2803;          //跟车状态
        public const int Changing = 2804;           //变道状态
        public const int Overtaking = 2805;         //超车状态
        public const int Passing_Through = 2806;    //转弯状态
        public const int Parking = 2807;            //停车状态
        public const int Terminate = 2808;          //终止状态
        public const int Waiting = 2809;            //等待状态
        public const int Passed = 2810;             //已通过临界区状态

        //车辆转弯情况标识位
        public const int PreTurn = 1;               //车辆转弯前
        public const int Turning = 2;               //车辆转弯中
        public const int AfterTurn = 3;             //车辆转弯后

        //车辆位置标志位
        public const int ArrivePreSections = 1;     //车辆在进入初始车道，未进入到临界区
        public const int ArriveSections = 2;        //车辆进入临界区
        public const int ArriveAfterSections = 3;   //车辆进入目标车道

        public const int LeaveInit = 0;              //车辆未离开初始车道，（可能在初始车道，或者也可能有一部分是在临界区之中）
        public const int LeavePreSections = 1;       //车辆离开初始车道
        public const int LeaveSections = 2;          //车辆离开临界区
        public const int LeaveAfterSections = 3;     //车辆离开目标车道

        

        /*车辆在路口的行进方向*/
        public const int Left = 1;                   //左转
        public const int Right = 2;                  //右转
        public const int Straight = 3;               //直行

        //车辆的到和离开
        public const int Arrive = 1;                 //到达
        public const int Leave = 2;                  //离开

        /*优先级设置*/
        public const int PrioPrefix = 7500;          //基础优先级
        public const int Prio_High = 7502;           //高优先级
        public const int Prio_Mid = 7501;            //中优先级
        public const int Prio_Low = 7500;            //低优先级

        //车辆类型
        public const int BigCar = 1;                 //大车
        public const int SmallCar = 2;               //小车

        //不同类型车辆物理尺寸
        public const double Big_Length = 4.5;        //大车长
        public const double Big_Width = 1.6;         //大车宽
        public const double Small_Length = 3.6;      //小车长
        public const double Small_Width = 1.5;       //小车宽
        
        //车辆标记位置位置
        public const int FrontMiddle = 1;            //车头中间位置
        public const int FrontLeft = 2;              //车头左
        public const int FrontRight = 3;             //车头右
        public const int BackLeft = 4;               //车尾左
        public const int BackRight = 5;              //车尾右

        //系统参数
        public const float TimeStep = 0.04f;         //步长
        public const int Precise = 4;                //精确位数
        //public const int MaxAuthNum = 4 * DisplayForm.AuthMax;             //最大授权车辆数目
        //public int MaxAuthNum = MainData.FormConfig.GetAuthorizeVehicleNumber() * 4;
        //public const int MaxAuthNum = 4 * 4;             //最大授权车辆数目
         
        public const float MaxTime = 999999;         //表示最大的时间
        public const float TotalTime = 1000.0f;      //模拟总时间 
        public static float RecordInterval = Definitions.TimeStep * 0.9f;   //记录一次车辆速度的间隔时间，一般取一个时间片

        //临界区数量，因为从1开始计数，所以比实际值大1
        public const int CSs_Count = 5;
        public const string Division = "_";                        //连续字符串的分隔符
        public const string Agent = "AGENT";                       //调度器代号
        public static readonly string[] FileName = new string[7];  //用于输出
        
        public static void init()
        {
            FileName[Definitions.ScheFIFO] = "S_FIFO";
            FileName[Definitions.ScheLight] = "S_Light";
            FileName[Definitions.ScheMultiFIFO] = "M_FIFO";
            FileName[Definitions.ScheMultiPrioFIFO] = "M_PriorFIFO";
            FileName[Definitions.ScheNew] = "S_New";
            FileName[Definitions.SchePrioFIFO] = "S_PriorFIFO";
        }
    }
}
